package wowraidmanager.server.service.flowlist;

import java.util.ArrayList;
import java.util.List;

import org.slim3.datastore.Datastore;

import wowraidmanager.client.service.flowlist.FlowlistService;
import wowraidmanager.server.meta.flowlist.FlowlistMeta;
import wowraidmanager.shared.model.flowlist.Flowlist;

import com.google.appengine.api.datastore.Key;

public class FlowlistServiceImpl implements FlowlistService{

    FlowlistMeta query = FlowlistMeta.get();

    public ArrayList<Flowlist> setflowlist(ArrayList<Flowlist> listFlowlist, String role){
        Datastore.put(listFlowlist);

        return (ArrayList<Flowlist>)Datastore.query(query).filter(query.spec.equal(role)).sort(query.spec.asc ,query.currentFlowNumber.asc).asList();
    }

    public void deleteRole(String role){
        List<Key> deleteListflowlist = Datastore.query(query).filter(query.spec.equal(role)).asKeyList();

        Datastore.delete(deleteListflowlist);
    }

    public ArrayList<Flowlist> getflowlist(){

        return (ArrayList<Flowlist>)Datastore.query(query).sort(query.spec.asc ,query.currentFlowNumber.asc).asList();
    }
}
